﻿using IBll;
using IDal;
using MD5Hash;
using Model;

namespace Bll
{
    public class StuBll : IStuBll
    {
         public StuBll(IStuDal<Stuber> stuD,IStuDal<UserMager> stuDa)
        {
            StuD = stuD;
            StuDa = stuDa;
        }

        public IStuDal<Stuber> StuD { get; }
        public IStuDal<UserMager> StuDa { get; }

        public EmpDto Shpw(int index, int size)
        {
            var stuber = StuD.GetValues();
            var userMager = StuDa.GetValues();
            var linq = from a in stuber
                       join b in userMager
                       on a.UserMagerId equals b.UserMagerId
                       select new
                       {
                           a.StuberId,
                           a.StuberName,
                           a.Num,
                           a.Adds,
                           a.Phone,
                           a.UserMagerId,
                           b.UserMagerName,
                          
                       };

                int m=linq.Count();
            var p = linq.OrderBy(x => x.StuberId).Skip((index - 1) * size).Take(size).ToList();
               return new EmpDto { Count = m,Mumber=p };
        }
    }
}
